package com.fy56.platform.logistics.common;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * Created by li on 2018-01-29.
 */
public class Page<T> implements Serializable {
    private Integer total;
    private Integer page;
    private Integer pageSize;
    private Integer records;
    private List<T> rows;
    private List<Map<String, Object>> listSum;

    public Page() {
    }

    public Page<T> init() {
        if (this.total == null) {
            this.total = Integer.valueOf(0);
        }

        if (this.page == null) {
            this.page = Integer.valueOf(1);
        }

        if (this.pageSize == null) {
            this.pageSize = Integer.valueOf(0);
        }

        if (this.records == null) {
            this.records = Integer.valueOf(0);
        }

        if (this.rows == null) {
            this.rows = new ArrayList();
        }

        if (this.pageSize.intValue() == 0) {
            return this;
        } else {
            this.total = Integer.valueOf(this.records.intValue() / this.pageSize.intValue());
            if (this.records.intValue() % this.pageSize.intValue() != 0 || this.total.intValue() == 0) {
                Integer var1 = this.total;
                Integer var2 = this.total = Integer.valueOf(this.total.intValue() + 1);
            }

            if (this.total.intValue() < this.page.intValue()) {
                this.total = this.page;
            }

            return this;
        }
    }

    public List<Map<String, Object>> getListSum() {
        return this.listSum;
    }

    public void setListSum(List<Map<String, Object>> listSum) {
        this.listSum = listSum;
    }

    public Integer getTotal() {
        return this.total;
    }

    public void setTotal(Integer total) {
        this.total = total;
    }

    public Integer getPage() {
        return this.page;
    }

    public void setPage(Integer page) {
        this.page = page;
    }

    public Integer getPageSize() {
        return this.pageSize;
    }

    public void setPageSize(Integer pageSize) {
        this.pageSize = pageSize;
    }

    public Integer getRecords() {
        return this.records;
    }

    public void setRecords(Integer records) {
        this.records = records;
    }

    public List<T> getRows() {
        return this.rows;
    }

    public void setRows(List<T> rows) {
        this.rows = rows;
    }
}
